package com.gpframework.module.order.domain.req;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gpframework.common.utils.StringUtils;
import com.gpframework.module.base.domain.req.BaseReq;
import com.gpframework.module.order.domain.GpFlowConfig;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;


/**
 * @ClassName GpFlowConfigReq
 * @Author gpframework
 * @Date 2023-06-16
 * @Version 1.0.0
 * @Description 列表查询信息体
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
public class GpFlowConfigReq extends BaseReq {
    private static final long serialVersionUID = 1L;

         @ApiModelProperty("品牌id")
     private String brandId;
     @ApiModelProperty("品牌名称")
     private String brandName;
     @ApiModelProperty("流转节点名称")
     private String name;
     @ApiModelProperty("绿色处理时长（最小值）")
     private Long greenMinDuration;
     @ApiModelProperty("绿色处理时长（最大值）")
     private Long greenMaxDuration;
     @ApiModelProperty("黄色处理时长（最小值）")
     private Long yellowMinDuration;
     @ApiModelProperty("黄色处理时长（最大值）")
     private Long yellowMaxDuration;
     @ApiModelProperty("红色处理时长")
     private Long redDuration;

    /**
    * @Description 生成查询wrapper
    * @Author greatplan@qq.com
    * @Date 2020-11-04 16:04
    * @Param [lqw]
    * @Param [isVO] 是否vo查询体，true的话走的是mapper.xml里面的查询语句，不过查询语法还是mybatis-plus，主要用于某些关联查询出一些非数据表字段
    * @Return void
    */
    public void generatorQuery(QueryWrapper<GpFlowConfig> lqw,boolean isVo) {
        String alias = "";
        if (isVo) {
            alias = "gp.";
            lqw.eq(alias+"del_status",0);
        }
        if (StringUtils.isNotBlank(this.getBrandId())){
        lqw.eq(alias+"brand_id" ,this.getBrandId());
        }
        if (StringUtils.isNotBlank(this.getBrandName())){
            lqw.like(alias+"brand_name",this.getBrandName());
        }
        if (StringUtils.isNotBlank(this.getName())){
            lqw.like(alias+"name",this.getName());
        }
        if (this.getGreenMinDuration() != null){
        lqw.eq(alias+"green_min_duration" ,this.getGreenMinDuration());
        }
        if (this.getGreenMaxDuration() != null){
        lqw.eq(alias+"green_max_duration" ,this.getGreenMaxDuration());
        }
        if (this.getYellowMinDuration() != null){
        lqw.eq(alias+"yellow_min_duration" ,this.getYellowMinDuration());
        }
        if (this.getYellowMaxDuration() != null){
        lqw.eq(alias+"yellow_max_duration" ,this.getYellowMaxDuration());
        }
        if (this.getRedDuration() != null){
        lqw.eq(alias+"red_duration" ,this.getRedDuration());
        }
    }
}
